using System;
using System.Windows.Forms;

namespace SSL_Server
{
    public partial class DomainConfigDialog : Form
    {
        public string DomainName { get; private set; }
        public string CertPath { get; private set; }
        public string CertPassword { get; private set; }
        public string ResponseContent { get; private set; }

        public DomainConfigDialog()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrWhiteSpace(txtDomain.Text))
            {
                MessageBox.Show("请输入域名");
                return;
            }

            if(string.IsNullOrWhiteSpace(txtCertPath.Text))
            {
                MessageBox.Show("请选择证书文件");
                return;
            }

            DomainName = txtDomain.Text;
            CertPath = txtCertPath.Text;
            CertPassword = txtCertPassword.Text;
            ResponseContent = txtResponse.Text;

            DialogResult = DialogResult.OK;
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                Filter = "证书文件(*.pfx)|*.pfx|所有文件(*.*)|*.*",
                Title = "选择证书文件"
            };

            if(dialog.ShowDialog() == DialogResult.OK)
            {
                txtCertPath.Text = dialog.FileName;
            }
        }
    }
}
